package com.samsung.booksmanagement;

import java.util.ArrayList;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

public class DatabaseSevice extends Service {

	private BookDatabase mDatabase;

	private DatabaseServiceBinder mBinder = new DatabaseServiceBinder();

	@Override
	public IBinder onBind(Intent intent) {
		return mBinder;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		mDatabase = new BookDatabase(this);
	}

	public class DatabaseServiceBinder extends Binder {
		public DatabaseSevice getDatabaseService() {
			return DatabaseSevice.this;
		}
	}

	// //////////////////////Book

	public ArrayList<Book> listAllBook() {
		return mDatabase.listAllBookSql();
	}

	public long addBook(Book book) {
		return mDatabase.addBookSql(book);
	}

	public int deleteBook(int key) {
		return mDatabase.deleteBookSql(key);
	}

	public int updateBook(int key, Book book) {
		return mDatabase.updateBookSql(key, book);
	}

	public ArrayList<Book> searchBook(String keyword) {
		return mDatabase.searchBookSql(keyword);
	}

	public Book viewBook(int _id) {
		return mDatabase.viewBookSql(_id);
	}

	// //////////////////////// Schedule
	public long addSchedule(Schedule s) {
		return mDatabase.addScheduleSql(s);
	}

	public int deleteSchedule(int key) {
		return mDatabase.deleteScheduleSql(key);
	}

	public int getIdScheduleByBookId(int bookId) {
		return mDatabase.getIdScheduleByBookIdSql(bookId);
	}
}
